package clientApp.utils;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;
import game.units.Character;

public class CharNode extends AbstractTableModel {

	public List<Character> characters = new ArrayList<Character>();
	
	@Override
	public int getColumnCount() {
		// Name, Race, Class, Level
		return 4;
	}

	@Override
	public int getRowCount() {
		return characters.size();
	}

	@Override
	public Object getValueAt(int row, int col) {
		Character character = characters.get(row);
		ArrayList<game.referenceValues.UnitClass> classes = character.getClasses();
		String classLvl = ""+classes.get(0).getLvl();
		String className = classes.get(0).getName();
		for (int i = 1; i < classes.size(); i++)
		{
			classLvl = classLvl +" | "+classes.get(i).getLvl();
			className = className +" | "+ classes.get(i).getName();
		}
		switch(col)
		{
		case 0:
			return character.getName();
		case 1:
			return character.getRace().getName();
		case 2:			
			return className;
		case 3:			
			return classLvl;
		default:
			return null;
		}
		
	}
	
	@Override
	public String getColumnName(int col) {
		switch(col)
		{
		case 0:
			return "Name";
		case 1:
			return "Race";
		case 2:			
			return "Class";
		case 3:			
			return "Level";
		default:
			return null;
		}
	}
	

	public List<Character> getCharacters() {
		return characters;
	}

	public void setCharacters(List<Character> characters) {
		this.characters = characters;
	}
	
	

}
